fix: bypass deployment protection for read
when fetching files in an edge function
#14147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When an edge function uses
read
, it needs to fetch the file. This can result in a 401 Unauthorized error if Vercel's deployment protection is enabled.This PR adds the automatically generated secret to bypass the protection when fetching the file. However, the user must have enabled protection bypass automation for it to work. See https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation
Not sure how to detect if the deployment is protected or not so we can tell the user to enable bypass if they run into a 401 error. Is it enough to throw this error if we receive the 401 error regardless of if protection has been enabled?
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
No test unless we can get a test app deployed through CI and perform playwright tests on it from there.
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits